<?php
    function the_thumbnail($post_ID){ 
        $attached_images = (array)get_posts( array(
                        				'post_type' => 'attachment',
                        				'numberposts' => 1,
                        				'post_status' => null,
                        				'post_parent' => $post_ID,
                        				'orderby' => 'menu_order',
                        				'order' => 'ASC'
                        			) );
        $thumbnail_id = $attached_images[0]->ID;  

		$src = wp_get_attachment_image_src( $thumbnail_id ,'normal' );
 
		if ( !empty( $src ) && is_string( $src[0] ) ) {
			$thumbnail = $src[0];
		}else{
		    $thumbnail = get_template_directory_uri()."/images/noimage.png";
		}   
   
	   if ( ! empty( $thumbnail ) && is_ssl() )
		  $thumbnail = str_replace( 'http://', 'https://', $thumbnail );
        
        return $thumbnail;
    }
    
    function the_product_name($post_ID){
        $product = get_post($post_ID);
        return $product->post_title;
    }
    
    function the_product_permalink($post_ID) {
    	return get_permalink($post_ID);
    }
    
    function the_base_info($post_ID,$width,$height){
        $thumbnail = the_thumbnail($post_ID);
        $resize = get_template_directory_uri()."/homepageLib/image.php/image.jpg?width=$width&height=$height&image=$thumbnail";
        
        echo "<div class='product-item'>";
        echo "<div class='prd-thumbnail'><a href='".the_product_permalink($post_ID)."'><img src='$resize' border='0' /></a></div>";
        echo "<div class='prd-title'>".the_product_name($post_ID)."</div>";
        echo "<div class='prd-price'>"._product_normal_price($post_ID)."</div>";
        echo "<div class='prd-show'><a href='".the_product_permalink($post_ID)."'><span>".__('Show detail','twentyten')."</span></a></div>";
        echo "</div>";  
       
    }
 ?>
 
 
 
 <?php
 
function _product_normal_price($post_ID) {
	$full_price = get_post_meta( $post_ID, '_wpsc_price', true );
	$special_price = get_post_meta( $post_ID, '_wpsc_special_price', true );
	$price = $full_price;
	
	if ( ($full_price > $special_price) && ($special_price > 0) )
		$price = $special_price;
		       
	$output = wpsc_currency_display( $price );
	return $output;
} 
?>
